//
//  FirstViewController.m
//  11_13_tableView
//
//  Created by lanou on 15/11/23.
//  Copyright © 2015年 changfengZhang. All rights reserved.
//

#import "FirstViewController.h"

@interface FirstViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, strong) UIView *v;

@property (nonatomic, strong) UITableView *tableview;

@property (nonatomic, strong) UIButton *btn1;

@property (nonatomic, strong) UIButton *btn2;

@property (nonatomic, strong) UIButton *btn3;

@end

@implementation FirstViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor orangeColor];
    
    self.navigationItem.title = @"第一页";
    
    [self p_setupViews];
    
    [self.tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
    self.tableview.dataSource = self;
    self.tableview.delegate = self;
}

- (void)p_setupViews
{
    self.v = [[UIView alloc] init];
    self.v.frame = CGRectMake(0, 64, self.view.bounds.size.width, 35);
    self.v.backgroundColor = [UIColor redColor];
    [self.view addSubview:self.v];
    
    self.tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.v.frame), self.view.bounds.size.width, self.view.bounds.size.height - CGRectGetMaxY(self.v.frame)) style:(UITableViewStylePlain)];
    [self.view addSubview:self.tableview];
    
    self.btn1 = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.btn1.frame = CGRectMake(0, 0, self.view.bounds.size.width / 3.0, CGRectGetHeight(self.v.frame));
    self.btn1.backgroundColor = [UIColor blueColor];
    [self.btn1 setTitle:@"one" forState:(UIControlStateNormal)];
    [self.v addSubview:self.btn1];
    
    self.btn2 = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.btn2.frame = CGRectMake(CGRectGetMaxX(self.btn1.frame), 0, CGRectGetWidth(self.btn1.frame), CGRectGetHeight(self.v.frame));
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    cell.textLabel.text = @"测试数据";
    
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
